/*
 * Usuario.java
 *
 * Created on 16 de octubre de 2007, 04:48 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package data;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Entity class Usuario
 * 
 * @author Fanny Paola
 */
@Entity
@Table(name = "usuario")
@NamedQueries( {
        @NamedQuery(name = "Usuario.findByUsername", query = "SELECT u FROM Usuario u WHERE u.username = :username"),
        @NamedQuery(name = "Usuario.findByNombre", query = "SELECT u FROM Usuario u WHERE u.nombre = :nombre"),
        @NamedQuery(name = "Usuario.findByPassword", query = "SELECT u FROM Usuario u WHERE u.password = :password"),
        @NamedQuery(name = "Usuario.findByPuesto", query = "SELECT u FROM Usuario u WHERE u.puesto = :puesto")
    })
public class Usuario implements Serializable {

    @Id
    @Column(name = "username", nullable = false)
    private String username;

    @Column(name = "nombre", nullable = false)
    private String nombre;

    @Column(name = "password", nullable = false)
    private String password;

    @Column(name = "puesto", nullable = false)
    private String puesto;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idUsuario")
    private Collection<Mesa> mesaCollection;
    
    /** Creates a new instance of Usuario */
    public Usuario() {
    }

    /**
     * Creates a new instance of Usuario with the specified values.
     * @param username the username of the Usuario
     */
    public Usuario(String username) {
        this.username = username;
    }

    /**
     * Creates a new instance of Usuario with the specified values.
     * @param username the username of the Usuario
     * @param nombre the nombre of the Usuario
     * @param password the password of the Usuario
     * @param puesto the puesto of the Usuario
     */
    public Usuario(String username, String nombre, String password, String puesto) {
        this.username = username;
        this.nombre = nombre;
        this.password = password;
        this.puesto = puesto;
    }

    /**
     * Gets the username of this Usuario.
     * @return the username
     */
    public String getUsername() {
        return this.username;
    }

    /**
     * Sets the username of this Usuario to the specified value.
     * @param username the new username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Gets the nombre of this Usuario.
     * @return the nombre
     */
    public String getNombre() {
        return this.nombre;
    }

    /**
     * Sets the nombre of this Usuario to the specified value.
     * @param nombre the new nombre
     */
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    /**
     * Gets the password of this Usuario.
     * @return the password
     */
    public String getPassword() {
        return this.password;
    }

    /**
     * Sets the password of this Usuario to the specified value.
     * @param password the new password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Gets the puesto of this Usuario.
     * @return the puesto
     */
    public String getPuesto() {
        return this.puesto;
    }

    /**
     * Sets the puesto of this Usuario to the specified value.
     * @param puesto the new puesto
     */
    public void setPuesto(String puesto) {
        this.puesto = puesto;
    }

    /**
     * Gets the mesaCollection of this Usuario.
     * @return the mesaCollection
     */
    public Collection<Mesa> getMesaCollection() {
        return this.mesaCollection;
    }

    /**
     * Sets the mesaCollection of this Usuario to the specified value.
     * @param mesaCollection the new mesaCollection
     */
    public void setMesaCollection(Collection<Mesa> mesaCollection) {
        this.mesaCollection = mesaCollection;
    }

    /**
     * Returns a hash code value for the object.  This implementation computes 
     * a hash code value based on the id fields in this object.
     * @return a hash code value for this object.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.username != null ? this.username.hashCode() : 0);
        return hash;
    }

    /**
     * Determines whether another object is equal to this Usuario.  The result is 
     * <code>true</code> if and only if the argument is not null and is a Usuario object that 
     * has the same id field values as this object.
     * @param object the reference object with which to compare
     * @return <code>true</code> if this object is the same as the argument;
     * <code>false</code> otherwise.
     */
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Usuario)) {
            return false;
        }
        Usuario other = (Usuario)object;
        if (this.username != other.username && (this.username == null || !this.username.equals(other.username))) return false;
        return true;
    }

    /**
     * Returns a string representation of the object.  This implementation constructs 
     * that representation based on the id fields.
     * @return a string representation of the object.
     */
    @Override
    public String toString() {
        return "data.Usuario[username=" + username + "]";
    }
    
}
